home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CDSupport / ClassAct / AmigaE / ClickTabExample.e < prev    next >
Text File  |  1997-07-09  |  5KB  |  160 lines

  1. /* ClickTabExample.e - Ported to E by Eric Sauvageau. */
  2.  
  3. OPT PREPROCESS
  4.  
  5. MODULE 'tools/constructors', 'tools/boopsi'
  6.  
  7. MODULE 'exec/types','exec/memory','dos/dos','dos/dosextens','exec/lists',
  8.        'exec/nodes','intuition','graphics','intuition/intuition',
  9.        'intuition/gadgetclass','intuition/imageclass',
  10.        'intuition/intuitionbase','intuition/classusr',
  11.        'intuition/gadgetclass','intuition/cghooks','intuition/icclass',
  12.        'intuition/classes','intuition/sghooks','graphics/gfxbase',
  13.        'graphics/text','graphics/gfxmacros','utility/tagitem','utility/hooks'
  14.  
  15.  
  16. MODULE 'clicktab','gadgets/clicktab','window','classes/window','layout',
  17.        'gadgets/layout', 'other/classact_macros'
  18.  
  19. DEF listitems:PTR TO mlh
  20.  
  21.  
  22. CONST ID_CLICKTAB =1
  23.  
  24.  
  25. PROC clickTabNodes(list:PTR TO lh, labels:PTR TO LONG)
  26. DEF node=NIL, i=0
  27.  
  28.    newlist(list)
  29.  
  30.    WHILE labels[i]
  31.  
  32.       IF (node := AllocClickTabNodeA([TNA_TEXT, labels[i],
  33.                                       TNA_NUMBER, i,
  34.                                       TNA_ENABLED, TRUE,
  35.                                       TNA_SPACING, 6,
  36.                                       TAG_DONE]))
  37.  
  38.          AddTail(list,node)
  39.       ENDIF
  40.  
  41.       INC i
  42.  
  43.    ENDWHILE
  44. ENDPROC
  45.  
  46.  
  47. PROC freeClickTabNodes(list:PTR TO lh)
  48. DEF node:PTR TO ln, nextnode:PTR TO ln
  49.  
  50.    node:= list.head
  51.  
  52.    WHILE (nextnode = node.succ)
  53.       FreeClickTabNode(node)
  54.       node := nextnode
  55.    ENDWHILE
  56.  
  57.    END list  -> Optional, the E cleanup code would do it for us anyway.
  58. ENDPROC
  59.  
  60. PROC main()
  61. DEF  win=NIL:PTR TO window, tab_object=NIL:PTR TO object, win_object=NIL:PTR TO object
  62. DEF  wait, signal, result, done = FALSE, code, tmpres,tmpres2
  63. DEF  names:PTR TO LONG
  64.  
  65.    names:=['Tab_1','Tab_2','Tab_3','Tab_4',NIL]
  66.  
  67. ->  Open the classes
  68.  
  69.    windowbase := OpenLibrary('window.class',0)
  70.    layoutbase := OpenLibrary('gadgets/layout.gadget',0)
  71.    clicktabbase := OpenLibrary('gadgets/clicktab.gadget',0)
  72.  
  73.    IF (windowbase AND layoutbase AND clicktabbase)
  74.       clickTabNodes(NEW listitems, names)
  75.  
  76.       /* Create the window object. */
  77.       win_object := WindowObject,
  78.                        WA_SCREENTITLE, 'ClassAct Copyright 1995, Phantom Development LLC.',
  79.                        WA_TITLE, 'ClassAct clicktab.gadget Example',
  80.                        WA_SIZEGADGET, TRUE,
  81.                        WA_LEFT, 40,
  82.                        WA_TOP, 30,
  83.                        WA_DEPTHGADGET, TRUE,
  84.                        WA_DRAGBAR, TRUE,
  85.                        WA_CLOSEGADGET, TRUE,
  86.                        WA_ACTIVATE, TRUE,
  87.                        WA_SMARTREFRESH, TRUE,
  88.                        WINDOW_PARENTGROUP, VLayoutObject,
  89.                           LAYOUT_SPACEOUTER, TRUE,
  90.                           LAYOUT_DEFERLAYOUT, TRUE,
  91.                           LAYOUT_ADDCHILD, tab_object := ClickTabObject,
  92.                              GA_ID, ID_CLICKTAB,
  93.                              CLICKTAB_LABELS, listitems,
  94.                              CLICKTAB_CURRENT, 0,
  95.                           End,
  96.                        End,
  97.                     End
  98.  
  99. -> Object creation sucessful?
  100.  
  101.       IF win_object
  102.  
  103. -> Open the window.
  104.  
  105.          IF (win := CA_OpenWindow(win_object))
  106.                 
  107. -> Obtain the window wait signal mask.
  108.  
  109.             GetAttr( WINDOW_SIGMASK, win_object, {signal})
  110.  
  111. -> Input Event Loop
  112.  
  113.             WHILE done = FALSE
  114.                wait:= Wait(signal OR SIGBREAKF_CTRL_C)
  115.  
  116.                IF (wait AND SIGBREAKF_CTRL_C)
  117.                   done := TRUE                    
  118.                ELSE
  119.  
  120.                   WHILE (result := domethod(win_object, [WM_HANDLEINPUT,{code}])) <> WMHI_LASTMSG
  121.                      tmpres := (result AND WMHI_CLASSMASK)
  122.                      SELECT tmpres
  123.          
  124.                         CASE WMHI_CLOSEWINDOW
  125.                              done := TRUE
  126.  
  127.                         CASE WMHI_GADGETUP
  128.                            tmpres2 := (result AND WMHI_GADGETMASK)
  129.  
  130.                            SELECT tmpres2
  131.                              CASE ID_CLICKTAB ; NOP
  132.                                            NOP
  133.                            ENDSELECT
  134.  
  135.                      ENDSELECT
  136.                   ENDWHILE
  137.                ENDIF
  138.             ENDWHILE
  139.          ENDIF
  140.  
  141.          /* Disposing of the window object will
  142.           * also close the window if it is
  143.           * already opened and it will dispose of
  144.           * all objects attached to it.
  145.           */
  146.           DisposeObject(win_object)
  147.       ENDIF
  148.    ENDIF
  149.  
  150.    freeClickTabNodes(listitems)
  151.  
  152.    /* Close the classes. */
  153.  
  154.    IF clicktabbase THEN CloseLibrary(clicktabbase)
  155.    IF layoutbase THEN CloseLibrary(layoutbase)
  156.    IF windowbase THEN CloseLibrary(windowbase)
  157.  
  158. ENDPROC
  159.  
  160.